CC= g++
CFLAGS=-std=c++0x -Wall

OBJ=Obj
LIBS= $(OBJ)/utf8.o $(OBJ)/log.o $(OBJ)/config.o $(OBJ)/authr.o $(OBJ)/nsr.o $(OBJ)/ns-client*.o $(OBJ)/ar-client*.o
DIR=FS
OBJ=Obj
BIN=Bin
HEADERS=

all: fs.file.cpp fs.rpc.c fs.client.cpp fs.server.cpp fs.service.cpp server test

fs.client.cpp: $(DIR)/fs.client.cpp $(DIR)/fs.client.h
	$(CC) $(CFLAGS) $(DIR)/fs.client.cpp -c -o $(OBJ)/fs-client.o

fs.file.cpp: $(DIR)/fs.file.cpp $(DIR)/fs.file.h
	$(CC) $(CFLAGS) $(DIR)/fs.file.cpp -c -o $(OBJ)/fs-client-file.o

fs.service.cpp: $(DIR)/fs.service.cpp $(DIR)/fs.rpc.h
	$(CC) $(CFLAGS) $(DIR)/fs.service.cpp -DLOGPATH=\"Bin/fs-journal\" -c -o $(DIR)/fs.service.o

fs.server.cpp: $(DIR)/fs.server.cpp $(DIR)/fs.server.h
	$(CC) $(CFLAGS) $(DIR)/fs.server.cpp -c -o $(DIR)/fs.server.o

fs.rpc.c: $(DIR)/fs.rpc_clnt.c $(DIR)/fs.rpc_xdr.c $(DIR)/fs.rpc_svc.c $(DIR)/fs.rpc.h
	$(CC) $(DIR)/fs.rpc_clnt.c -c -o $(OBJ)/fs-client-rpc.o
	$(CC) $(DIR)/fs.rpc_xdr.c  -c -o $(OBJ)/fs-client-xdr.o
	$(CC) $(DIR)/fs.rpc_svc.c  -c -o $(DIR)/fs.rpc_svc.o

server: $(OBJ)/fs-client-file.o $(DIR)/fs.service.o $(DIR)/fs.rpc_svc.o $(DIR)/fs.server.o $(OBJ)/fs-client-xdr.o 
	$(CC) $(CFLAGS) $(LIBS) $(OBJ)/fs-client-file.o $(DIR)/fs.service.o $(DIR)/fs.rpc_svc.o $(DIR)/fs.server.o $(OBJ)/fs-client-xdr.o -o $(BIN)/fs-server
	rm $(DIR)/*.o

test: $(DIR)/test.cpp $(DIR)/fs.client.h $(OBJ)/fs-client-file.o $(OBJ)/fs-client.o $(OBJ)/fs-client-rpc.o $(OBJ)/fs-client-xdr.o 
	$(CC) $(CFLAGS)  $(DIR)/test.cpp -c -o $(BIN)/test.o
	$(CC) $(CFLAGS) $(LIBS) $(OBJ)/fs-client-file.o $(OBJ)/fs-client.o $(OBJ)/fs-client-rpc.o $(OBJ)/fs-client-xdr.o $(BIN)/test.o -o $(BIN)/fs-test


